package com.server.common.logistice.sfd;

import com.google.gson.annotations.SerializedName;
import com.server.common.logistics.response.LogisticsResponse;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.ObjectUtils;

import java.util.List;

@Getter
@Setter
public class SFDResponse<T> extends LogisticsResponse{

    //错误信息
    private String apiErrorMsg;

    //响应ID
    private String apiResponseID;

    //响应参数
    private String apiResultCode;

    //返回数据
    private ApiResultData<T> apiResultData;

    @Override
    public Boolean responseOk() {
        return "A1000".equals(apiResultCode);
    }

    @Override
    public Boolean dataEmpty() {
        return ObjectUtils.isEmpty(apiResultData);
    }

    @Getter
    @Setter
    public static class ApiResultData<T> extends LogisticsResponse {
        @SerializedName("success")
        private Boolean success;
        @SerializedName("errorCode")
        private String errorCode;
        @SerializedName("errorMsg")
        private String errorMsg;
        @SerializedName("msgData")
        private T msgData;

        //打印面单
        @SerializedName("obj")
        private PrintLabelObj printLabelObj;

        @Getter
        @Setter
        public static class PrintLabelObj{

            private List<PrintFile> files;

            private String clientCode;

            private String templateCode;

            private String fileType;

            @Getter
            @Setter
            public static class PrintFile{

                private String url;

                private String token;

                private String waybillNo;

                private String seqNo;

                private String areaNo;

                private String pageNo;
            }

        }

        @Override
        public Boolean responseOk() {
            return success;
        }

        @Override
        public Boolean dataEmpty() {
            return ObjectUtils.isEmpty(msgData);
        }
    }

}
